<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.prime.com.tr/ui" template="/layout/principal.xhtml">

    <ui:define name="content">

        <h1 class="title ui-widget-header">
            <h:outputText value="Nueva Campaña" />
        </h1>

        <h:form enctype="multipart/form-data">
            <p:growl id="growl1" showDetail="true" life="3000" />
            <h:panelGrid columns="2" cellspacing="5" cellpadding="5">
                <h:outputText value="Base de Llamadas : * " />
                <p:fileUpload id="fileUploadId" label="Explorar" uploadLabel="Subir base" cancelLabel="Cancelar"
                    value="Explorar" fileUploadListener="#{master.handleFileUpload}" mode="advanced" allowTypes="csv"
                    update="growl1 dgMaster" style="width: 250px;" />
            </h:panelGrid>

            <p:dataGrid id="dgMaster" var="m" value="#{master.listCabecera}" columns="5" rows="10" paginator="true"
                effect="true" effectSpeed="low" paginatorPosition="bottom">
                <p:column>
                    <p:panel header="#{m.name}">
                        <h:panelGrid columns="3">
                            <p:selectBooleanCheckbox value="#{m.checked}" />
                            <p:spacer width="10" />
                            <p:selectOneMenu value="#{m.type}" effect="drop" style="width: 120px;">
                                <f:selectItems value="#{initLoad.siColumnType}" />
                            </p:selectOneMenu>
                        </h:panelGrid>
                    </p:panel>
                </p:column>
            </p:dataGrid>
        </h:form>

        <p:separator style="height: 2px" />
        <p:separator style="height: 2px" />

        <h:form id="form">
            <p:growl id="growl" showDetail="true" life="3000" />

            <h:panelGrid columns="5">
                <h:outputLabel value="Formulario : " for="pickListId" />
                <p:pickList id="pickListId" value="#{master.listFormulario}" var="f" itemLabel="#{f.nombre}"
                    itemValue="#{f}" converter="formConverter" addAllLabel="Adicionar Todos" addLabel="Adicionar"
                    removeAllLabel="Remover Todos" removeLabel="Remover" effect="fade" immediate="true"
                    valueChangeListener="#{master.change}">
                    <f:facet name="sourceCaption">
                        <h:outputText value="Disponible" />
                    </f:facet>
                    <f:facet name="targetCaption">
                        <h:outputText value="Seleccionado" />
                    </f:facet>
                </p:pickList>
                <p:spacer width="10" />
                <h:outputLabel value="Script : " for="scriptId" />

                <h:panelGrid columns="1">
                    <p:selectOneMenu value="#{master.scriptId}" effect="drop" style="width: 120px;">
                        <f:selectItems value="#{initLoad.siScript}" />
                    </p:selectOneMenu>
                    <p:editor id="scriptId" value="#{master.script}" height="250" width="400" />
                </h:panelGrid>
            </h:panelGrid>

            <p:separator style="height: 2px" />
            <p:separator style="height: 2px" />

            <h:panelGrid columns="2">
                <p:commandButton value="Guardar" action="#{master.guardar}" update="growl" style="width: 200px;"
                    image="ui-icon ui-icon-disk" />
                <p:commandButton value="Cancelar" action="goListarMaster" ajax="false" immediate="true"
                    style="width: 200px;" image="ui-icon ui-icon-close" />
            </h:panelGrid>

        </h:form>

    </ui:define>
</ui:composition>